<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>博客</title>

    <meta name="description" content="Source code generated using layoutit.com">
    <meta name="author" content="LayoutIt!">

    <link href="../static/css/bootstrap.min.css" rel="stylesheet">
    <link href="../static/css/style.css" rel="stylesheet">
</head>
<body style="padding: 50px;background-image: url('../static/images/blogsbg.jpg')">
<div class="container-fluid">
	<div class="row">
		<div class="col-md-2">
		</div>
		<div class="col-md-8">
			<form role="form" style="background: #ffffffaa;padding: 10px;border-radius: 5px;" id="blogs">
				<div class="form-group">

					<label >
						标题
					</label>
					<input type="text" class="form-control" name="title" />
				</div>
				<div class="form-group">

					<label  >
						标签
					</label>
					<input type="text" class="form-control" name="tags" />
				</div>
                <textarea rows="35" style="width: 100%;" name="detail"></textarea>
				<input type="button" class="btn btn-primary" id="publish" value="发布">
                <input type="button" class="btn btn-primary" id="save" value="保存">
                <a href="/" class="btn btn-primary">
					返回首页
				</a>
                <input type="hidden" name="username" value="{{ username }}">
			</form>
		</div>
		<div class="col-md-2">
		</div>
	</div>
</div>
<script src="../static/js/jquery.min.js"></script>
<script type="text/javascript">
    $("#publish").click(function (e) {
        $.ajax({
            url:'/publish/1/',
            type:'post',
            data:$("#blogs").serialize(),
            success:function (code) {
                if( code.status=="success"){
                    confirm("发布成功！")
                }
                else{
                    alert("发布失败！")
                }
            },
            error:function (e) {

            }
        })
    })

    $("#save").click(function (e) {
        $.ajax({
            url:'/publish/2/',
            type:'post',
            data:$("#blogs").serialize(),
            success:function (status) {

            },
            error:function (e) {

            }
        })
    })
</script>
</body>
</html>